#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
using namespace std;
int shu(string a)
{
	int ans=0,i;
	int len=a.length();
	for(i=0;i<len;i++)
		ans=ans*10+(a[i]-'0');
	return ans;
}
int len(int n)
{
	int ans=0;
	if(n<=0) 
	{
		n=-n;
		ans++;
	};
	while(n!=0)
	{
		n/=10;
		ans++;
	};
	return ans;
}
int main()
{
	int n;
	int i;
	string a,b,c,t;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(a=="a")
		{
			t="a";
			cin>>b>>c;
			printf("%d+%d=%d\n",shu(b),shu(c),shu(b)+shu(c));
			printf("%d\n",len(shu(b))+len(shu(c))+len(shu(b)+shu(c))+2);
		}
		else if(a=="b")
		{
			t="b";
			cin>>b>>c;
			printf("%d-%d=%d\n",shu(b),shu(c),shu(b)-shu(c));
			printf("%d\n",len(shu(b))+len(shu(c))+len(shu(b)-shu(c))+2);
		}
		else if(a=="c")
		{
			t="c";
			cin>>b>>c;
			printf("%d*%d=%d\n",shu(b),shu(c),shu(b)*shu(c));
			printf("%d\n",len(shu(b))+len(shu(c))+len(shu(b)*shu(c))+2);
		}
		else
		{
			if(t=="a")
			{
			cin>>b;
			printf("%d+%d=%d\n",shu(a),shu(b),shu(a)+shu(b));
			printf("%d\n",len(shu(a))+len(shu(b))+len(shu(a)+shu(b))+2);
			};
			if(t=="b")
			{
			cin>>b;
			printf("%d+%d=%d\n",shu(a),shu(b),shu(a)-shu(b));
			printf("%d\n",len(shu(a))+len(shu(b))+len(shu(a)-shu(b))+2);
			};
			if(t=="c")
			{
			cin>>b;
			printf("%d+%d=%d\n",shu(a),shu(b),shu(a)*shu(b));
			printf("%d\n",len(shu(a))+len(shu(b))+len(shu(a)*shu(b))+2);
			};
		};
	};
	return 0;
}
